#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__title__ = ''
__author__ = 'S126_wendy'
__mtime__ = '2017/3/8'
"""


#encoding=utf-8
#python version 3.4

import requests
import os

from .support.cookieUtil import convertStrToDict

def getFirstPage():
    cookieStr = "pac_uid=1_790947589; tvfe_boss_uuid=7bb1f90025e2bbfe; gaduid=57d10cc1cda81; msuid=ix1eueb9rd7er3e8uuw57ubelrmwwgq2nlx2bfuj; o_cookie=790947589; pgv_pvid=9590355513; ptcz=4241e320be9ad14ac93cb42360544d4bdca22324388f785739209b450813a2b8; pt2gguin=o0790947589; uin=o0790947589; skey=@LVoez8VVf; ptisp=ctc; MANYOU_SESSIONID_bf895=a1281c993501a9e4ccb644ca3c5bbbb1; qqUser=%7B%22uin%22%3A790947589%2C%22nic"
    #payload = {"Cookie": cookieStr}
    cookies = convertStrToDict(cookieStr)
    memberNumber = 126;
    responseOfPage = requests.get("http://qgc.qq.com/314962432/t/" + str(memberNumber), cookies= cookies)
    #print(responseOfPage.url)
    #print(responseOfPage.status_code)
    #print(os.getcwd())
    #print(os.path.exists("E:\wendygit\scalersForum\src\s126_wendy\pages\member" + str(memberNumber)))
    if not os.path.exists("E:\wendygit\scalersForum\src\s126_wendy\pages\member" + str(memberNumber)):
        os.mkdir("E:\wendygit\scalersForum\src\s126_wendy\pages\member" + str(memberNumber))
    file_126 = open("E:\wendygit\scalersForum\src\s126_wendy\pages\member" + str(memberNumber) + "\page_1.html","wb")
    file_126.write(responseOfPage.content)
    file_126.close()
